package com.lecture.java8.thread;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

/**
 * @author luyn
 * @version 1.0
 * @description
 * @date 2021/10/26 10:25
 */
public class TestCallableService {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        List<Future<String>> futureList = new ArrayList<>();
        TestCallable testCallable = new TestCallable();
        Future<String> future = executorService.submit(testCallable);
        futureList.add(future);
        executorService.shutdown();
        for (Future<String> futureStr : futureList) {
            try  {
                System.out.println(futureStr.get());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
